#include <bits/stdc++.h>
using namespace std;
int n,a[100010],x[100010];
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    x[0]=1e9;
    int xl=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=x[xl])
        {
            x[++xl]=a[i];
        }
        else
        {
            int pos=lower_bound(x+1,x+xl+1,a[i],greater<int>())-x-1;
            x[pos]=a[i];
        }
    }
    cout<<xl;
    return 0;
}
